{include file="Public:header" /}
<style>
    .li-inline,li{
        list-style: none;
    }
    .li-inline>li{
        display: inline-block;
    }
</style>
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5 style="line-height: 30px;font-weight: bold;">权限列表</h5>
                <a href="{:url('Auth/group')}" class="btn btn-sm btn-info" style="margin-left: 10px;">返回上一页</a>
            </div>
            <div class="ibox-content">
                <div id="form" class="form-horizontal m-t">
                    <input type="hidden" name="gid" value="{$group.id}">
                    <div class="form-group">
                        <h3 style="text-align: center;">{$group.title}</h3>
                    </div>
                    <div class="form-group">
                        <ul>
                            {volist name="list" id="vo"}
                            {empty name="vo._data"}
                            <li class="li-check">
                                <label class="checkbox-inline i-checks">
                                    <input type="checkbox" value="{$vo.id}" name="rule_id[]" {in name="$vo.id" value="$group.rules"} checked {/in}> <i></i>{$vo.title}
                                </label>
                            </li>
                            {else /}
                            <li class="li-check">
                                <label class="checkbox-inline i-checks">
                                    <input type="checkbox" value="{$vo.id}" name="rule_id[]" {in name="$vo.id" value="$group.rules"} checked {/in}> <i></i>{$vo.title}
                                </label>
                                <ul>
                                    {volist name="vo._data" id="v"}
                                    <li class="li-check">
                                        <label class="checkbox-inline i-checks">
                                            <input type="checkbox" value="{$v.id}" name="rule_id[]" {in name="$v.id" value="$group.rules"} checked {/in}> <i></i>{$v.title}
                                        </label>
                                        <ul class="li-inline">
                                            {notempty name="v._data"}
                                            {volist name="v._data" id="v_c"}
                                                <li class="li-check">
                                                    <label class="checkbox-inline i-checks">
                                                        <input type="checkbox" value="{$v_c.id}" name="rule_id[]" {in name="$v_c.id" value="$group.rules"} checked {/in}> <i></i>{$v_c.title}
                                                    </label>
                                                </li>
                                            {/volist}
                                            {/notempty}
                                        </ul>
                                    </li>
                                    {/volist}
                                </ul>
                            </li>
                            {/empty}
                            {/volist}
                        </ul>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-6">
                            <button class="submit btn btn-primary">提交</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="Public:footer" /}
{include file="Public:formAjaxSubmit" /}
<script>
    $(function () {
        $('input').on('ifClicked ifUnchecked',function (event) {
            if(event.type == 'ifClicked')
            {
                $(this).parents('.li-check').eq(0).find("input[type='checkbox']").iCheck('check');
                $(this).parents('.li-inline').parents('.li-check').children('.i-checks').iCheck('check');
            }else{
                $(this).parents('.li-check').eq(0).find("input[type='checkbox']").iCheck('uncheck');
            }

        });
    });
    formAjaxSubmit("{:url('Auth/groupSetRules')}");
</script>